import request from '@/utils/request'
import { urlPrefix } from './config'

export function loginByUsername(username, password) {
  const data = {
    username,
    password
  }
  return request({
    url: `${urlPrefix}/authorizations`,
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: `${urlPrefix}/authorizations/current`,
    method: 'delete'
  })
}

export function refreshToken() {
  return request({
    url: `${urlPrefix}/authorizations/current`,
    method: 'put'
  })
}

export function getUserInfo() {
  return request({
    url: `${urlPrefix}/user`,
    method: 'get'
  })
}

